import ajax from '../untils/request.js'

// 获取频道内容
export const getArticles = (channelID, timestamp) => {
  return ajax({
    url: '/app/v1_1/articles',
    method: 'GET',
    params: {
      channel_id: channelID,
      timestamp: timestamp,
      with_top: 1
    }
  })
}

// 不感兴趣请求处理
export const unlikeArticles = (articleID) => {
  return ajax({
    url: '/app/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: articleID
    }
  })
}

// 举报文章
export const reports = (articleID, reportType, remark) => {
  return ajax({
    url: '/app/v1_0/article/reports',
    method: 'POST',
    data: {
      target: articleID,
      type: reportType,
      remark: remark
    }
  })
}

// 获取新闻详情
export const getArticleDetail = (articleID) => {
  return ajax({
    url: '/app/v1_0/articles/' + articleID,
    method: 'GET'
  })
}

// 关注用户
export const followedAuthor = (autID) => {
  return ajax({
    url: '/app/v1_0/user/followings',
    method: 'POST',
    data: {
      target: autID
    }
  })
}

// 取消关注用户
export const unfollowedAuthor = (autID) => {
  return ajax({
    url: '/app/v1_0/user/followings/' + autID,
    method: 'DELETE'
  })
}

// 点赞文章
export const giveLike = (articleID) => {
  return ajax({
    url: '/app/v1_0/article/likings',
    method: 'POST',
    data: {
      target: articleID
    }
  })
}

// 取消点赞
export const cancleLike = (articleID) => {
  return ajax({
    url: '/app/v1_0/article/likings/' + articleID,
    method: 'DELETE'
  })
}

// 取消不喜欢文章
export const cancleUnlike = (articleID) => {
  return ajax({
    url: '/app/v1_0/article/dislikes/' + articleID,
    method: 'DELETE'
  })
}

// //父组件如果想要修改子组件内的属性和方法可以通过ref进行引用
// <son ref="son2"></son>

// 通过this.$refs.xxx来获取想要修改的属性和方法
